use "${clean}newspaper_analysis.dta", clear

keep if north == 1

// creating some variables
replace year = year - 1860
gen period = year > 0

// standardizing variables
egen county_surban = std(county_urban_percent)
egen county_srugged = std(county_ruggedness)
egen county_spostoffice = std(county_postoffice_area)

// keeping the sample consistent
cap drop sample
gen sample = 1
foreach var of varlist $county_npcontrols {
	replace sample = . if `var' == .
}

// estimates
xtset pub_id

estimates clear
eststo: xtreg singular c.year##i.period##i.lincoln_county if sample == 1, re cluster(pub_id)
estadd local fe "No"

eststo: xtreg singular c.year##i.period##i.lincoln_county if sample == 1, fe cluster(pub_id)
estadd local fe "Publication"

eststo: xtreg singular c.year##i.period##i.lincoln_county ${county_npcontrols} if sample == 1, re cluster(pub_id)
estadd local fe "No"

eststo: xtreg singular c.year##i.period##i.lincoln_county ${county_npcontrols} if sample == 1, fe cluster(pub_id)
estadd local fe "Publication"





esttab est* using "${output}TabD6_np_election_fulltable.tex", replace ///
	b(%8.3f) se(%8.3f) ///
	starlevels(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
	scalars("fe Fixed Effects") ///
	keep( ///
		year ///
		1.period ///
		1.lincoln_county ///
		1.period#c.year ///
		1.lincoln_county#c.year ///
		1.period#1.lincoln_county ///
		1.period#1.lincoln_county#c.year ///
		county_surban county_spostoffice county_srugged county_anyriver county_anycanal _cons ///
		) ///
	order( ///
		year ///
		1.period ///
		1.lincoln_county ///
		1.period#c.year ///
		1.lincoln_county#c.year ///
		1.period#1.lincoln_county ///
		1.period#1.lincoln_county#c.year ///
		county_surban county_spostoffice county_srugged county_anyriver county_anycanal _cons ///
		) ///
	coeflabels( ///
		year "Year" ///
		1.period "After 1860" ///
		1.lincoln_county "Lincoln County" ///
		1.period#c.year "Year $\times$ After 1860" ///
		1.lincoln_county#c.year "Year $\times$ Lincoln County" ///
		1.period#1.lincoln_county "After 1860 $\times$ Lincoln County" ///
		1.period#1.lincoln_county#c.year "Year $\times$ After 1860 $\times$ Lincoln County" ///
		county_surban "County \% Urban (std)" ///
		county_spostoffice "Post Office Density (std)" ///
		county_srugged "Terrain Ruggedness (std)" ///
		county_anyriver "County on River" ///
		county_anycanal "County on Canal" ///
		_cons "Constant" ///
		) ///
	nodepvars nomtitles nonotes ///
	nogaps nolines posthead(\midrule) prefoot(\midrule) postfoot(\bottomrule \end{tabular}}) ///
	tex compress	
